import { createRouter, createWebHistory } from "vue-router";
// import login from "../view"
// 路由规则
const routes = [
  {
    path: "/",
    name: "index",
    redirect: "/login",
  },
  //ManagerInfo
  {
    path: "/login",
    name: "login",

    component: () => import("../view/login/LoginView.vue"),
  },
  //ManagerInfo
  {
    path: "/:pathMatch(.*)*",
    name: "Notfound",

    component: () => import("../view/404/NotFound.vue"),
  },
  {
    path: "/PhotoVr",
    name: "PhotoVr",

    component: () => import("../components/PhotoVr.vue"),
  },
  {
    path: "/home",
    name: "home",

    component: () => import("../view/home/HomeView.vue"),
   
  },
];

//根据路由规则创建路由
const router = createRouter({
  history: createWebHistory(""),
  routes,
});

// router.beforeEach((to, from, next) => {
//   // 判断有没有登录
//   if (!sessionStorage.getItem("token")) {
//     if (to.name == "login") {
//       next();
//     } else {
//       router.push("login");
//     }
//   } else {
//     next();
//   }
// });
// router.beforeEach((to, from, next) => {
//   if (to.path === "/login") {
//     next();
//   } else {
//     let token = localStorage.getItem("token");
//     if (token === null || token === "") {
//       next("/login");
//     } else {
//       next();
//     }
//   }
//   if (to.meta.title) {
//     document.title = to.meta.title;
//   } else {
//     document.title = "";
//   }
// });

export default router;
